<template>
	<!-- transferrecord转账记录 -->
	<view class="t_wp">
		<view class="t_tab">
			<view class="t_tab_item" :class="{active:active==1}" @click="navtap(1)">收款记录</view>
			<view class="t_tab_item" :class="{active:active==2}" @click="navtap(2)">付款记录</view>
		</view>
		<view class="t_detailed">明细：（
			<view class="t_money_item" v-if="active==1">
				<text>收款：{{content.money}}元</text>
				<text>收款：{{content.credit1}}米币</text>
			</view>
			<view class="t_money_item" v-if="active==2">
				<text>付款：{{content.money}}元</text>
				<text>付款：{{content.credit1}}米币</text>
			</view>）
		</view>
		<view class="t_list">
			<view class="t_item" v-for="(item,i) in list" :key="i">
				<view class="t_li">
					<text class="t_li_title">{{item.title}}</text>
					<text>总金额：<text class="s_money">{{item.price}}</text></text>
				</view>
				<view class="t_li">
					<text class="t_li_title s_time">{{item.createtime}}</text>
					<text v-if="item.credit1">米币：<text class="s_money">{{item.credit1}}</text></text>
					<text v-if="!item.credit1&&item.money">现金：<text class="s_money">{{item.money}}</text></text>
				</view>
				<view class="t_li">
					<text class="t_li_title">备注：<text class="s_remarks">{{item.remark}}</text></text>
					<text v-if="item.credit1&&item.money">现金：<text class="s_money">{{item.money}}</text></text>
				</view>
			</view>
		</view>
		<view class="loading_message">
			<image v-if="isloading" src="../../static/business/loading.gif"></image>
			<view v-if="isempty">到底了~</view>
		</view>
		<bot-tomtab></bot-tomtab>
	</view>
</template>

<script>
	import BotTomtab from '@/components/bottomtab.vue';
	export default {
		components: {
			BotTomtab
		},
		data() {
			return {
				uid:'',
				
				active: 1,
				
				content:{credit1:0,money:0},
				
				page: 0,
				list: [],
				isempty: false,
				isloading: false,
				stopload: false,


			}
		},
		onReachBottom() {
			if (this.active == 1) this.getilist();
			if (this.active == 2) this.gettlist();
		},
		onLoad(option) {
			this.uid=option.uid;
			this.getilist();
		},
		methods: {
			navtap(v) {
				if (this.active == v) return;
				this.content={credit1:0,money:0};
				this.active = v;
				this.stopload = false;
				this.page = 0;
				this.isempty = false;
				this.list = [];
				if (v == 1) this.getilist();
				if (v == 2) this.gettlist();
			},
			assignment(data){
				this.content=data.content;
				let length = data.log.length;
				this.list = this.list.concat(data.log);
				this.isempty = length <= 0 ? true : false;
				this.stopload = length <= 0 ? true : false;
			},
			gettlist() {
				if (this.stopload) return;
				this.stopload = true;
				this.page += 1;
				this.isloading = true;
				this.$axios('groupManager/trans', 'POST', 'supplier', {
					page: this.page,
					uid:this.uid,
				}).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.assignment(res.data.data);
					}
				})
			},
			getilist() {
				if (this.stopload) return;
				this.stopload = true;
				this.page += 1;
				this.isloading = true;
				this.$axios('groupManager/income', 'POST', 'supplier', {
					page: this.page,
					uid:this.uid,
				}).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.assignment(res.data.data);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f2f2f2;
		color: $font-color-dark;
		padding-bottom: 130upx;
	}

	.t_wp {
		padding-bottom: 100upx;
	}

	.t_tab {
		background: #fff;
		display: flex;
		align-items: center;
		line-height: 90upx;
		position: fixed;
		width: 100%;
	}

	.t_tab_item {
		text-align: center;
		position: relative;
		width: 50%;
	}

	.active {
		color: $base-color;
	}

	.active:after {
		content: '';
		position: absolute;
		border-bottom: 2px $base-color solid;
		left: 50%;
		transform: translateX(-50%);
		bottom: 0;
		width: 20%;
	}

	.t_nav {
		background-color: $base-color;
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		height: 260upx;
	}

	.t_nav_number {
		font-size: 40upx;
		line-height: 60upx;
	}

	.t_detailed {
		display: flex;
		align-items: flex-end;
		font-size: 30upx;
		padding: 110upx 20upx 20upx;
	}

	.t_money_item {
		margin-left: 20upx;
		font-size: 24upx;
	}

	.t_money_item text {
		margin-right: 20upx;
	}

	.t_item {
		background-color: #fff;
		border-radius: 10upx;
		padding: 20upx;
		margin: 0 20upx 20upx;
	}

	.t_li {
		display: flex;
		align-items: center;
	}

	.t_li text {
		line-height: 40upx;
	}

	.s_time {
		color: $font-color-light;
	}

	.t_li_title {
		flex: 1;
		margin-right: 10upx;
	}

	.s_money {
		font-weight: bold;
	}

	.s_remarks {
		color: #0062CC;
	}

	.loading_message image {
		display: block;
		margin: 0 auto;
		height: 60upx;
		width: 60upx;
	}

	.loading_message view {
		text-align: center;
		color: $font-color-spec;
	}
</style>
